<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Code Igniter
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package		CodeIgniter
 * @author		Gabriel Popa
 * @copyright	Copyright (c) 2008, IELLO-DEV
 * @license		http://www.codeignitor.com/user_guide/license.html
 * @link		http://www.codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

class Ajax_request {
	
	function Ajax_request(){
		$this->CI =& get_instance();
		log_message('debug', "AJAX <safe request> library initialized");
		
	}

	
	/**
	 * check ajax request if true; else redirect to login
	 * @return 
	 * @param $url Object
	 * @param $request Object
	 */	
	function _check_request($url,$request){
		$CFG =& load_class('Config');

		if($this->CI->session->userdata('us_')){
			if($request == true){
				log_message('debug', "Check AJAX request: saferequest = true to url:".$url);
				return $request;
			} elseif($request == false) {
				log_message('error', "Check AJAX request: saferequest = false to url:".$url);
				redirect('','location');
			} 
		}else {
				log_message('error', "Check AJAX request session: Session = false");
				redirect('','location');				
		}
	}
}
?>